home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume7 / xmail / patch1.03 < prev    next >
Encoding:
Internet Message Format  |  1990-06-01  |  53.6 KB

  1. Path: uunet!seismo!ukma!rex!uflorida!haven!decuac!decwrl!elroy.jpl.nasa.gov!ames!sun-barr!newstop!sun!news
  2. From: news@sun.Eng.Sun.COM (news)
  3. Newsgroups: comp.sources.x
  4. Subject: v07i083: xmail -- Mail front end for X11, Patch1, Part03/06
  5. Message-ID: <136498@sun.Eng.Sun.COM>
  6. Date: 1 Jun 90 03:41:12 GMT
  7. Organization: Sun Microsystems, Inc. - Mtn View, CA
  8. Lines: 1498
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: parns.nsc.com!michael (Michael C. Wagnitz)
  12. Posting-number: Volume 7, Issue 83
  13. Archive-name: xmail/patch1.03
  14. Patch-To: xmail: Volume 6, Issue 41-46
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 3 (of 5)."
  23. # Contents:  Patch.01c
  24. # Wrapped by michael@harley on Tue May 29 10:33:50 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'Patch.01c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Patch.01c'\"
  28. else
  29. echo shar: Extracting \"'Patch.01c'\" \(51482 characters\)
  30. sed "s/^X//" >'Patch.01c' <<'END_OF_FILE'
  31. X!  else {
  32. X      if ((s = getenv("HOME")) == NULL) s = "";
  33. X      sprintf(buf, "%s/.mailrc", s);
  34. X     }
  35. X   return((char *)buf);
  36. X  } /* mailrcFile */
  37. X***************
  38. X*** 210,233 ****
  39. X  char    *item;
  40. X  {
  41. X   FILE    *fp;
  42. X!  char    *s, buf[BUFSIZ];
  43. X  
  44. X  
  45. X-  s = "";
  46. X   if ((fp = fopen(mailrcFile(), "r")) != NULL) {
  47. X      while (s = fgets(buf, BUFSIZ, fp)) {
  48. X!           if (strncmp(buf, "set", 3) == 0) {
  49. X!              for (s = &buf[3]; *s == ' ' || *s == '\t'; s++);
  50. X!              if (strncmp(s, item, strlen(item)) == 0) {
  51. X!                 s = s + strlen(item) + 1;
  52. X!                 if (*s == '\"')        /* if surrounded by quotes */
  53. X!                    buf[strlen(buf) - 2] = '\0';
  54. X!                 else {
  55. X!                    buf[strlen(buf) - 1] = '\0';
  56. X!                    --s;
  57. X                    }
  58. X!                 strcpy(buf, ++s);
  59. X!                 s = XtNewString(buf);
  60. X                  break;
  61. X                 }
  62. X              }
  63. X--- 245,280 ----
  64. X  char    *item;
  65. X  {
  66. X   FILE    *fp;
  67. X!  char    *s = NULL;
  68. X!  char    buf[BUFSIZ];
  69. X  
  70. X  
  71. X   if ((fp = fopen(mailrcFile(), "r")) != NULL) {
  72. X      while (s = fgets(buf, BUFSIZ, fp)) {
  73. X!           if (strncmp(buf, "set", 3) == 0) {    /* if this is a 'set' record */
  74. X!              s = &buf[3];        /* starting just beyond the 'set'... */
  75. X!              while (*s) {        /* there may be multiple assignments */
  76. X!                 for (; *s && (*s == ' ' || *s == '\t' || *s == '\n'); s++);
  77. X!                 if (*s) {
  78. X!                    if (strncmp(s, item, strlen(item)) == 0)
  79. X!                       break;
  80. X                    }
  81. X!                 for (; *s && *s != ' ' && *s != '\t' && *s != '\n'; s++);
  82. X!                }
  83. X!              if (*s) {                /* we have found a match */
  84. X!                 s = s + strlen(item);        /* look for a value to it */
  85. X!                 if (*s++ != '=') {        /* variable only, no value */
  86. X!                    s = XtNewString("True");    /* return a boolean string */
  87. X!                   } else {
  88. X!                    if (*s == '\"')        /* if surrounded by quotes */
  89. X!                       buf[strlen(buf) - 2] = '\0';
  90. X!                    else {
  91. X!                       buf[strlen(buf) - 1] = '\0';
  92. X!                       --s;
  93. X!                      }
  94. X!                    strcpy(buf, ++s);
  95. X!                    s = XtNewString(buf);
  96. X!                   }
  97. X                  break;
  98. X                 }
  99. X              }
  100. X*** ../v1.0/global.h    Sun May 27 21:05:51 1990
  101. X--- global.h    Sun May 27 21:09:59 1990
  102. X***************
  103. X*** 44,49 ****
  104. X--- 44,50 ----
  105. X  
  106. X  /* HelpText.c */
  107. X  
  108. X+ extern String        Bcc_Help_Text;
  109. X  extern String        Cc_Help_Text;
  110. X  extern String        Copy_Help_Text;
  111. X  extern String        Delete_Help_Text;
  112. X***************
  113. X*** 68,73 ****
  114. X--- 69,76 ----
  115. X  
  116. X  /* actions.c */
  117. X  
  118. X+ extern XtActionProc    CheckInsert();        /* for the file window */
  119. X+ extern XtActionProc    DeleteChar();        /* for deletes (file window) */
  120. X  extern XtActionProc    DeleteLine();        /* in the file window */
  121. X  extern XtActionProc    DeleteWord();        /* also in the file window */
  122. X  extern XtActionProc    DoAutograph();        /* call Autograph callback */
  123. X***************
  124. X*** 79,85 ****
  125. X  extern XtActionProc    DoSelected();        /* DoCmd w/ selected message */
  126. X  extern XtActionProc    Folder();        /* execute folder command */
  127. X  extern XtActionProc    Iconify();        /* iconification request */
  128. X- extern XtActionProc    InsertSpace();        /* for deletes (file window) */
  129. X  extern XtActionProc    MyNotify();        /* invokes callbacks w/ param */
  130. X  extern XtActionProc    NextField();        /* warps pointer to data fld */
  131. X  extern XtActionProc    PrintMsg();        /* send mail to the printer */
  132. X--- 82,87 ----
  133. X***************
  134. X*** 88,93 ****
  135. X--- 90,96 ----
  136. X  extern XtActionProc    SetDirectory();        /* create folder files list */
  137. X  extern XtActionProc    SetFolders();        /* create a list of folders */
  138. X  extern XtActionProc    SetHelp();        /* Position help popup text */
  139. X+ extern XtActionProc    SetMenu();        /* Position set_menu popup */
  140. X  extern XtActionProc    SetPopup();        /* Position relative to owner */
  141. X  extern XtActionProc    SetSelect();        /* reposition select mark */
  142. X  extern XtActionProc    Quit();            /* termination procedure */
  143. X***************
  144. X*** 99,104 ****
  145. X--- 102,108 ----
  146. X  extern XtCallbackProc    DoIt();            /* callback do specified cmd */
  147. X  extern XtCallbackProc    DoPrint();        /* callback printer execution */
  148. X  extern XtCallbackProc    DoQuit();        /* callback termination func */
  149. X+ extern XtCallbackProc    DoSet();        /* callback to toggle options */
  150. X  extern XtCallbackProc    DoWith();        /* do cmd with arguments */
  151. X  extern XtCallbackProc    GetAliasName();        /* retrieve alias name */
  152. X  extern XtCallbackProc    GetFolderName();    /* retrieve folder name */
  153. X***************
  154. X*** 121,126 ****
  155. X--- 125,131 ----
  156. X  
  157. X  extern int         index_handler();    /* highlight the msg number */
  158. X  extern int         file_handler();        /* handle change of folder */
  159. X+ extern XtEventHandler    icon_handler();        /* handle iconify changes */
  160. X  
  161. X  /* mail.c */
  162. X  
  163. X***************
  164. X*** 137,147 ****
  165. X  /* utils.c */
  166. X  
  167. X  extern void         Bell();            /* disp. error and sound bell */
  168. X  extern void         Normalize();        /* position to end of text */
  169. X  extern int         PositionToMsgNumber();    /* convert pos to msg number */
  170. X  extern void         writeText();        /* write text to buffer */
  171. X  extern XtTextPosition    TextGetLastPos();    /* get last pos of text */
  172. X! extern void        UpdateTitleBar();    /* file name and msg count */
  173. X  extern void         writeTo();        /* send text data to window */
  174. X  
  175. X  /* windows.c */
  176. X--- 142,153 ----
  177. X  /* utils.c */
  178. X  
  179. X  extern void         Bell();            /* disp. error and sound bell */
  180. X+ extern void         markIndex();        /* add/replace index marker */
  181. X  extern void         Normalize();        /* position to end of text */
  182. X  extern int         PositionToMsgNumber();    /* convert pos to msg number */
  183. X  extern void         writeText();        /* write text to buffer */
  184. X  extern XtTextPosition    TextGetLastPos();    /* get last pos of text */
  185. X! extern int        UpdateTitleBar();    /* file name and msg count */
  186. X  extern void         writeTo();        /* send text data to window */
  187. X  
  188. X  /* windows.c */
  189. X***************
  190. X*** 159,165 ****
  191. X  extern void         CreateSubWindows();    /* all subwindows of xmail */
  192. X  extern void        CreateTextWindow();    /* another text window */
  193. X  extern void        CreateTitleBar();    /* a text output window */
  194. X! extern Widget        CreateInputWindow();    /* for To, Subject, and Cc */
  195. X  
  196. X  /* xmail.c */
  197. X  
  198. X--- 165,171 ----
  199. X  extern void         CreateSubWindows();    /* all subwindows of xmail */
  200. X  extern void        CreateTextWindow();    /* another text window */
  201. X  extern void        CreateTitleBar();    /* a text output window */
  202. X! extern Widget        CreateInputWindow();    /* To, Subject, Cc, and Bcc */
  203. X  
  204. X  /* xmail.c */
  205. X  
  206. X***************
  207. X*** 175,183 ****
  208. X  extern char     SubjBuf[BUFSIZ];    /* message subject        */
  209. X  extern char     InReply[BUFSIZ];    /* reply reference string    */
  210. X  extern char     CcBuf[BUFSIZ];        /* message Cc list        */
  211. X  extern char     tmpName[BUFSIZ];    /* message temporary filename    */
  212. X! extern char     MailPrompt[20];        /* mail program prompt string    */
  213. X! extern char    *HelpNames[23];        /* array of help window names    */
  214. X  extern char    **mailargv;        /* array passed to mail child    */
  215. X  
  216. X  extern Pixmap    hatch;            /* cross_weave, used for Newmail */
  217. X--- 181,190 ----
  218. X  extern char     SubjBuf[BUFSIZ];    /* message subject        */
  219. X  extern char     InReply[BUFSIZ];    /* reply reference string    */
  220. X  extern char     CcBuf[BUFSIZ];        /* message Cc list        */
  221. X+ extern char     BccBuf[BUFSIZ];        /* message Bcc list        */
  222. X  extern char     tmpName[BUFSIZ];    /* message temporary filename    */
  223. X! extern char     *MailPrompt;        /* mail program prompt string    */
  224. X! extern char    *HelpNames[24];        /* array of help window names    */
  225. X  extern char    **mailargv;        /* array passed to mail child    */
  226. X  
  227. X  extern Pixmap    hatch;            /* cross_weave, used for Newmail */
  228. X***************
  229. X*** 187,196 ****
  230. X  
  231. X  extern AliasRecPtr    *aliases;    /* array of mail alias strings    */
  232. X  extern XmailResources    XMail;        /* XMail application resources */
  233. X! extern XtTextSource    HelpStrings[22];
  234. X  extern XFontStruct    *TextFontStr, *HelpFontStr;
  235. X  
  236. X- extern FILE    *mailfp;        /* file pointer to mail process */
  237. X  extern int    mail_fd;        /* descriptor to mail process i/o */
  238. X  
  239. X  extern int    mailargc;        /* counter passed to mail child    */
  240. X--- 194,202 ----
  241. X  
  242. X  extern AliasRecPtr    *aliases;    /* array of mail alias strings    */
  243. X  extern XmailResources    XMail;        /* XMail application resources */
  244. X! extern XtTextSource    HelpStrings[23];
  245. X  extern XFontStruct    *TextFontStr, *HelpFontStr;
  246. X  
  247. X  extern int    mail_fd;        /* descriptor to mail process i/o */
  248. X  
  249. X  extern int    mailargc;        /* counter passed to mail child    */
  250. X*** ../v1.0/handler.c    Sun May 27 21:05:52 1990
  251. X--- handler.c    Sun May 27 21:11:36 1990
  252. X***************
  253. X*** 38,45 ****
  254. X   * The following software modules were created and are Copyrighted by National
  255. X   * Semiconductor Corporation:
  256. X   *
  257. X!  * 1. index_handler: and
  258. X!  * 2. file_handler.
  259. X   *
  260. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  261. X   *
  262. X--- 38,47 ----
  263. X   * The following software modules were created and are Copyrighted by National
  264. X   * Semiconductor Corporation:
  265. X   *
  266. X!  * 1. In_System_Folder:
  267. X!  * 2. icon_handler:
  268. X!  * 3. index_handler: and
  269. X!  * 4. file_handler.
  270. X   *
  271. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  272. X   *
  273. X***************
  274. X*** 49,66 ****
  275. X  #include <ctype.h>
  276. X  #include "global.h"
  277. X  #include "xmailregex.h"
  278. X  
  279. X  /*
  280. X  ** @(#)index_handler() - mark index line of specified or current mail message
  281. X  */
  282. X  int
  283. X! index_handler(msg_num)
  284. X  int    msg_num;
  285. X  {
  286. X!  char        *c, *s, *strchr();
  287. X   Arg            args[2];
  288. X   Cardinal     j, k;
  289. X!  Widget        w;
  290. X   XtTextPosition pos, top;
  291. X  
  292. X  
  293. X--- 51,169 ----
  294. X  #include <ctype.h>
  295. X  #include "global.h"
  296. X  #include "xmailregex.h"
  297. X+ #include "MailwatchP.h"
  298. X  
  299. X+ #if XtSpecificationRelease >= 4
  300. X+ #include <X11/Xaw/LabelP.h>        /* R4 */
  301. X+ #else
  302. X+ #include <X11/LabelP.h>            /* R3 */
  303. X+ #endif
  304. X+ 
  305. X  /*
  306. X+ ** This is unwise, because it depends on a Label Widget's private parts.
  307. X+ ** Examine the current value of the titleBar label and return true/false
  308. X+ ** does it match the system mail folder name?
  309. X+ */
  310. X+ int
  311. X+ In_System_Folder(w)
  312. X+ Widget    w;
  313. X+ {
  314. X+  int         result;
  315. X+  char         *cp, *index(), *rindex(), buf[BUFSIZ];
  316. X+  MailwatchWidget mb = (MailwatchWidget) WidgetOf(w, "mailbox");
  317. X+  LabelWidget     tb = (LabelWidget) WidgetOf(WidgetOf(WidgetOf(toplevel,
  318. X+                     "topBox"), "titleBar"), "titleBar");
  319. X+ 
  320. X+  strcpy(buf, tb->label.label);        /* XtGetValues didn't work in R3 */
  321. X+  if ((cp = rindex(buf, '"')) == NULL) result = FALSE;
  322. X+  else {                    /* if a current folder name exists */
  323. X+     *cp = NULL;                /* chop off the rest of the label */
  324. X+     if ((cp = index(buf, '"')) == NULL) result = FALSE;
  325. X+     else result = (strcmp(mb->mailbox.filename, ++cp) == 0) ? TRUE : FALSE;
  326. X+    }
  327. X+  return(result);
  328. X+ } /* In_System_Folder */
  329. X+ 
  330. X+ 
  331. X+ /*
  332. X+ ** Process map and unmap events for the icon widget to manage iconify and
  333. X+ ** deiconify events and switch to/from a bogus mail folder.  This allows users
  334. X+ ** to access mail from another process without colliding with an open folder.
  335. X+ ** Once the bogus mail folder is accessed, we unlink it, to avoid having to
  336. X+ ** explicitly remove it later.
  337. X+ */
  338. X+ XtEventHandler
  339. X+ icon_handler(w, client_data, event)
  340. X+ Widget    w;
  341. X+ caddr_t    client_data;
  342. X+ XEvent    *event;
  343. X+ {
  344. X+  FILE    *fp;
  345. X+  char    *cp, cmd[BUFSIZ];
  346. X+  static Boolean    In_Bogus_Mail_File = False;    /* TRUE when we go iconic */
  347. X+  static Boolean    Was_System_Folder = False;    /* TRUE if we had been in */
  348. X+ 
  349. X+ 
  350. X+  if (mailpid) {
  351. X+     switch (event->type) {
  352. X+            case MapNotify :
  353. X+                 if (! In_Bogus_Mail_File) {
  354. X+                    if (In_System_Folder(w))
  355. X+             Was_System_Folder = True;
  356. X+                    (void) sprintf(cmd, "%s+", tmpName);
  357. X+                    if (fp = fopen(cmd, "w")) {    /* create a bogus mail file */
  358. X+                       (void) fprintf(fp, "\n");
  359. X+                       fclose(fp);
  360. X+                       (void) sprintf(cmd, "file %s+", tmpName);
  361. X+                       cp = QueryMail(cmd);    /* focus our attention there */
  362. X+                       XtFree(cp);
  363. X+                       (void) sprintf(cmd, "%s+", tmpName);
  364. X+                       (void) unlink(cmd);    /* toss it now that we're in */
  365. X+                       In_Bogus_Mail_File = True;
  366. X+                      }
  367. X+                   }
  368. X+                 break;
  369. X+            case UnmapNotify :
  370. X+                 if (In_Bogus_Mail_File) {
  371. X+                    if (strcmp(Command, "Start") != 0) {    /* if not starting up */
  372. X+                       if (Was_System_Folder) {        /* go to system file */
  373. X+                          (void) strcpy(Command, "file %\n");
  374. X+                         } else {            /* go to prev. file */
  375. X+                          (void) strcpy(Command, "file #\n");
  376. X+                         }
  377. X+                      } else {
  378. X+                       if (XMail.MFileName) {    /* start in specified folder */
  379. X+                          (void) sprintf(Command, "file %s\n", XMail.MFileName);
  380. X+                         } else {        /* or else use system folder */
  381. X+                          (void) strcpy(Command, "file %\n");
  382. X+                         }
  383. X+                      }
  384. X+                    writeMail(Command);        /* let parser do the updating */
  385. X+                    In_Bogus_Mail_File = False;
  386. X+                    Was_System_Folder = False;
  387. X+                   } else if (In_System_Folder(w))
  388. X+                             UnsetNewmail(WidgetOf(WidgetOf(WidgetOf(toplevel,
  389. X+                                          "topBox"), "commandPanel"), "Folder"));
  390. X+                 break;
  391. X+            default:
  392. X+                 break;
  393. X+           } /* end - switch on event type */
  394. X+    } /* end - if mail is active */
  395. X+ } /* icon_handler */
  396. X+ 
  397. X+ 
  398. X+ /*
  399. X  ** @(#)index_handler() - mark index line of specified or current mail message
  400. X  */
  401. X  int
  402. X! index_handler(msg_num, undeleting)
  403. X  int    msg_num;
  404. X+ int    undeleting;
  405. X  {
  406. X!  char        *c, *s, *index();
  407. X   Arg            args[2];
  408. X   Cardinal     j, k;
  409. X!  Widget        iw;
  410. X   XtTextPosition pos, top;
  411. X  
  412. X  
  413. X***************
  414. X*** 74,80 ****
  415. X     }
  416. X  
  417. X   if (k <= 50)
  418. X!     for (s = IndexBuf, j = k; j > 1 && (c = strchr(s,'\n')); j--) s = c + 1;
  419. X   else {                        /* if index is fairly large */
  420. X      for (s = &IndexBuf[strlen(IndexBuf) - 2]; s > IndexBuf && *s != '\n'; s--);
  421. X      for (c = s + 1; *c && !isdigit(*c); c++);
  422. X--- 177,183 ----
  423. X     }
  424. X  
  425. X   if (k <= 50)
  426. X!     for (s = IndexBuf, j = k; j > 1 && (c = index(s,'\n')); j--) s = c + 1;
  427. X   else {                        /* if index is fairly large */
  428. X      for (s = &IndexBuf[strlen(IndexBuf) - 2]; s > IndexBuf && *s != '\n'; s--);
  429. X      for (c = s + 1; *c && !isdigit(*c); c++);
  430. X***************
  431. X*** 91,99 ****
  432. X       s++;
  433. X      }
  434. X  
  435. X!  if (*(s + 1) == 'D') {                /* If this is a deleted msg */
  436. X      for (;*s && *(s + 1) == 'D';) {        /* try looking above deletes */
  437. X!         if (! (c = strchr(s,'\n'))) break;    /* don't go past end of buf */
  438. X          s = c + 1;
  439. X         }
  440. X      for (;s > IndexBuf && *(s + 1) == 'D';) {
  441. X--- 194,202 ----
  442. X       s++;
  443. X      }
  444. X  
  445. X!  if (! undeleting && *(s + 1) == 'D') {        /* If this is a deleted msg */
  446. X      for (;*s && *(s + 1) == 'D';) {        /* try looking above deletes */
  447. X!         if (! (c = index(s,'\n'))) break;    /* don't go past end of buf */
  448. X          s = c + 1;
  449. X         }
  450. X      for (;s > IndexBuf && *(s + 1) == 'D';) {
  451. X***************
  452. X*** 106,123 ****
  453. X  
  454. X   pos = s - IndexBuf;                /* resolve our position */
  455. X  
  456. X!  w = WidgetOf(WidgetOf(toplevel, "vpane"), "indexWindow");
  457. X  
  458. X!  XtTextSetInsertionPoint(w, pos);
  459. X  
  460. X-  SetSelect(w, NULL, NULL, NULL);
  461. X- 
  462. X   return(j);                    /* return msg actually found */
  463. X  } /* index_handler */
  464. X  
  465. X  
  466. X  /*
  467. X! ** @(#)file_handler() - Handle output of Start, file, and delete commands
  468. X  ** If *Show_Last: resource is NOT False and show_latest is true, show last
  469. X  ** message in list, if none are marked as new.
  470. X  */
  471. X--- 209,224 ----
  472. X  
  473. X   pos = s - IndexBuf;                /* resolve our position */
  474. X  
  475. X!  iw = WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow");
  476. X  
  477. X!  XtTextSetInsertionPoint(iw, pos);
  478. X  
  479. X   return(j);                    /* return msg actually found */
  480. X  } /* index_handler */
  481. X  
  482. X  
  483. X  /*
  484. X! ** @(#)file_handler() - Handle output of Start and file commands
  485. X  ** If *Show_Last: resource is NOT False and show_latest is true, show last
  486. X  ** message in list, if none are marked as new.
  487. X  */
  488. X***************
  489. X*** 124,132 ****
  490. X  file_handler(show_latest)
  491. X  int    show_latest;
  492. X  {
  493. X!  Widget    w;
  494. X!  char    msgnum_str[10], *c, *s, *p, *strchr();
  495. X!  int    msg_num = 0;                /* zero means no message */
  496. X  
  497. X  
  498. X   c = QueryMail("=");                /* Get current mail msg num. */
  499. X--- 225,233 ----
  500. X  file_handler(show_latest)
  501. X  int    show_latest;
  502. X  {
  503. X!  char    *c, *s, *p, *index(), msgnum_str[10];
  504. X!  int    more_than_one, msg_num = 0;        /* zero means no message */
  505. X!  Widget    iw = WidgetOf(WidgetOf(toplevel, "topBox"), "indexWindow");
  506. X  
  507. X  
  508. X   c = QueryMail("=");                /* Get current mail msg num. */
  509. X***************
  510. X*** 136,142 ****
  511. X   XtFree(c);
  512. X  
  513. X   c = QueryMail("file");                /* Forces current msg to one */
  514. X!  UpdateTitleBar(c);
  515. X   XtFree(c);
  516. X  
  517. X   if (strcmp(Command, "Start") == 0) {        /* unless we're at Start, in */
  518. X--- 237,243 ----
  519. X   XtFree(c);
  520. X  
  521. X   c = QueryMail("file");                /* Forces current msg to one */
  522. X!  (void) UpdateTitleBar(c);
  523. X   XtFree(c);
  524. X  
  525. X   if (strcmp(Command, "Start") == 0) {        /* unless we're at Start, in */
  526. X***************
  527. X*** 148,155 ****
  528. X   s = QueryMail("h");
  529. X   if (strncmp(s, "No applicable messages", 22) == 0) {
  530. X      Bell(s);
  531. X!     writeText(WidgetOf(WidgetOf(toplevel, "vpane"), "indexWindow"), " ", 0);
  532. X!     writeTo(WidgetOf(WidgetOf(toplevel, "vpane"), "textWindow"), " ");
  533. X     } else {
  534. X  /*
  535. X  ** find message pointer caret and replace it with a space
  536. X--- 249,256 ----
  537. X   s = QueryMail("h");
  538. X   if (strncmp(s, "No applicable messages", 22) == 0) {
  539. X      Bell(s);
  540. X!     writeText(iw, " ", FALSE);
  541. X!     writeTo(WidgetOf(WidgetOf(toplevel, "topBox"), "textWindow"), " ");
  542. X     } else {
  543. X  /*
  544. X  ** find message pointer caret and replace it with a space
  545. X***************
  546. X*** 164,174 ****
  547. X               }
  548. X           }
  549. X  /*
  550. X! ** If current message is not marked as new or unread, show_latest is true, and
  551. X! ** the Show_Last resource is not false, select the last message in the header.
  552. X  */
  553. X!    if (show_latest && XMail.Show_Last) {
  554. X!       if (*(c+1) != 'N' && *(c+1) != 'U') {    /* If this is not a special */
  555. X           p = c;                    /* find the last message */
  556. X           if (c == s) {                /* if would've started @ One */
  557. X              for (p = &s[strlen(s)-2]; p > s && *p != '\n'; p--);
  558. X--- 265,279 ----
  559. X               }
  560. X           }
  561. X  /*
  562. X! ** If current message is marked new or unread, ensure as many of new message
  563. X! ** headers as possible are displayed in the index window (especially the
  564. X! ** current one), else if show_latest is true, and the Show_Last resource is
  565. X! ** not false, select the last message in the header.
  566. X  */
  567. X!    more_than_one = FALSE;            /* set a flag for new/unread */
  568. X!    if (*(c+1) == 'N' || *(c+1) == 'U') more_than_one = TRUE;
  569. X!    else {
  570. X!       if (show_latest && XMail.Show_Last) {
  571. X           p = c;                    /* find the last message */
  572. X           if (c == s) {                /* if would've started @ One */
  573. X              for (p = &s[strlen(s)-2]; p > s && *p != '\n'; p--);
  574. X***************
  575. X*** 175,181 ****
  576. X              p++;                /* go to last line of buffer */
  577. X             } else {
  578. X              for (;*++c && *(c+1) != 'N' && *(c+1) != 'U';) {
  579. X!                 if (! (c = strchr(p,'\n')))
  580. X                     break;            /* don't go past end of buf */
  581. X                  p = c + 1;
  582. X                 }
  583. X--- 280,286 ----
  584. X              p++;                /* go to last line of buffer */
  585. X             } else {
  586. X              for (;*++c && *(c+1) != 'N' && *(c+1) != 'U';) {
  587. X!                 if (! (c = index(p,'\n')))
  588. X                     break;            /* don't go past end of buf */
  589. X                  p = c + 1;
  590. X                 }
  591. X***************
  592. X*** 186,202 ****
  593. X          }
  594. X       }
  595. X  /*
  596. X! ** write the header info to the index window
  597. X  */
  598. X!     writeText(WidgetOf(WidgetOf(toplevel, "vpane"), "indexWindow"), s, 0);
  599. X  /*
  600. X! ** return the current mail message number
  601. X  */
  602. X      msg_num = atoi(msgnum_str);
  603. X  /*
  604. X  ** highlight the current message's header line index number
  605. X  */
  606. X!     index_handler(msg_num);
  607. X     }
  608. X   XtFree(s);
  609. X   return(msg_num);
  610. X--- 291,314 ----
  611. X          }
  612. X       }
  613. X  /*
  614. X! ** Write the header info into the index window buffer, replacing existing info.
  615. X  */
  616. X!     writeText(iw, s, FALSE);
  617. X  /*
  618. X! ** Ensure if we are seeing new or unread messages that as many as possible are
  619. X! ** displayed in the index window, to reduce the amount of scrolling required
  620. X! ** when reading(/deleting) them.
  621. X  */
  622. X+     if (more_than_one)
  623. X+        XtTextSetInsertionPoint(iw, TextGetLastPos(iw));
  624. X+ /*
  625. X+ ** Return the current mail message number.
  626. X+ */
  627. X      msg_num = atoi(msgnum_str);
  628. X  /*
  629. X  ** highlight the current message's header line index number
  630. X  */
  631. X!     index_handler(msg_num, 0);
  632. X     }
  633. X   XtFree(s);
  634. X   return(msg_num);
  635. X*** ../v1.0/mail.c    Sun May 27 21:05:53 1990
  636. X--- mail.c    Sun May 27 21:11:36 1990
  637. X***************
  638. X*** 47,54 ****
  639. X  
  640. X  #include "global.h"
  641. X  
  642. X! #ifndef    DEFAULT_EDITOR
  643. X! #define    DEFAULT_EDITOR    "/usr/ucb/vi";
  644. X  #endif
  645. X  
  646. X  /*
  647. X--- 47,54 ----
  648. X  
  649. X  #include "global.h"
  650. X  
  651. X! #ifndef    DEFAULT_VISUAL
  652. X! #define    DEFAULT_VISUAL    "/usr/ucb/vi"
  653. X  #endif
  654. X  
  655. X  /*
  656. X***************
  657. X*** 74,81 ****
  658. X  writeMail(s) 
  659. X  char *s;
  660. X  {
  661. X!  fputs(s, mailfp);
  662. X!  fflush(mailfp);
  663. X  } /* writeMail */
  664. X  
  665. X  
  666. X--- 74,80 ----
  667. X  writeMail(s) 
  668. X  char *s;
  669. X  {
  670. X!  write(mail_fd, s, strlen(s));
  671. X  } /* writeMail */
  672. X  
  673. X  
  674. X***************
  675. X*** 87,188 ****
  676. X  sendMail(parent)
  677. X  Widget parent;
  678. X  {
  679. X!  Arg            args[MAXARGS];
  680. X!  Cardinal        n;
  681. X   Display        *ad;
  682. X   Widget            Popup, Layout;
  683. X!  Widget            lab1, lab2, lab3;
  684. X!  Widget            To, Subject, Cclist, Last;
  685. X   Window            aw, dumy;
  686. X!  String            Editor;
  687. X   menuList_p        *list;
  688. X   menuList        b1, b2, b3;
  689. X!  char            cmd[BUFSIZ];
  690. X   int            x, y, scn;
  691. X  
  692. X  
  693. X!  aw  = XtWindow(WidgetOf(WidgetOf(toplevel, "vpane"), "statusWindow"));
  694. X!  ad  = XtDisplay(WidgetOf(WidgetOf(toplevel, "vpane"), "statusWindow"));
  695. X   scn = DefaultScreen(ad);
  696. X  
  697. X!  XTranslateCoordinates(ad, aw, RootWindow(ad, scn), XMail.menuX, XMail.menuY,
  698. X!                         &x, &y, &dumy);
  699. X  
  700. X   scn = XMail.shellWidth - 100;
  701. X  
  702. X!  n = 0;
  703. X!  XtSetArg(args[n], XtNinput, True);                    n++;
  704. X!  XtSetArg(args[n], XtNwidth, scn);                    n++;
  705. X!  XtSetArg(args[n], XtNheight, XMail.textMinHeight);            n++;
  706. X!  XtSetArg(args[n], XtNborderWidth, 2);                    n++;
  707. X!  XtSetArg(args[n], XtNx, x);                        n++;
  708. X!  XtSetArg(args[n], XtNy, y);                        n++;
  709. X!  Popup = XtCreatePopupShell("popup", overrideShellWidgetClass,parent,args,n);
  710. X  
  711. X!  n = 0;
  712. X!  XtSetArg(args[n], XtNdefaultDistance, 2);                n++;
  713. X!  Layout = XtCreateManagedWidget("SubjCc", formWidgetClass, Popup, args, n);
  714. X  
  715. X!  n = 0;
  716. X!  XtSetArg(args[n], XtNfromVert, NULL);                    n++;
  717. X!  XtSetArg(args[n], XtNfromHoriz, NULL);                    n++;
  718. X!  XtSetArg(args[n], XtNlabel, "To:      ");                n++;
  719. X!  XtSetArg(args[n], XtNborderWidth, 0);                    n++;
  720. X!  XtSetArg(args[n], XtNfont, TextFontStr);                n++;
  721. X!  XtSetArg(args[n], XtNheight, XMail.buttonHeight);            n++;
  722. X!  XtSetArg(args[n], XtNjustify, XtJustifyLeft);                n++;
  723. X!  XtSetArg(args[n], XtNinternalHeight, 0);                n++;
  724. X!  XtSetArg(args[n], XtNinternalWidth, 1);                n++;
  725. X!  lab1 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, n);
  726. X  
  727. X   To = CreateInputWindow(Layout, "To", Recipient, BUFSIZ);
  728. X-  n = 0;
  729. X-  XtSetArg(args[n], XtNfromVert, NULL);                    n++;
  730. X-  XtSetArg(args[n], XtNfromHoriz, lab1);                    n++;
  731. X-  XtSetValues(To, args, n);
  732. X  
  733. X   AddHelpText(To, "To", To_Help_Text);
  734. X  
  735. X!  n = 0;
  736. X!  XtSetArg(args[n], XtNfromVert, lab1);                    n++;
  737. X!  XtSetArg(args[n], XtNfromHoriz, NULL);                    n++;
  738. X!  XtSetArg(args[n], XtNlabel, "Subject: ");                n++;
  739. X!  n = 9;
  740. X!  lab2 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, n);
  741. X  
  742. X   Subject = CreateInputWindow(Layout, "Subject", SubjBuf, BUFSIZ);
  743. X-  n = 0;
  744. X-  XtSetArg(args[n], XtNfromVert, To);                    n++;
  745. X-  XtSetArg(args[n], XtNfromHoriz, lab2);                    n++;
  746. X-  XtSetValues(Subject, args, n);
  747. X  
  748. X   AddHelpText(Subject, "Subject", Subject_Help_Text);
  749. X  
  750. X!  n = 0;
  751. X!  XtSetArg(args[n], XtNfromVert, lab2);                    n++;
  752. X!  XtSetArg(args[n], XtNfromHoriz, NULL);                    n++;
  753. X!  XtSetArg(args[n], XtNlabel, "Cc:      ");                n++;
  754. X!  n = 9;
  755. X!  lab3 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, n);
  756. X  
  757. X   Cclist = CreateInputWindow(Layout, "Cc", CcBuf, BUFSIZ);
  758. X-  n = 0;
  759. X-  XtSetArg(args[n], XtNfromVert, Subject);                n++;
  760. X-  XtSetArg(args[n], XtNfromHoriz, lab3);                    n++;
  761. X-  XtSetValues(Cclist, args, n);
  762. X  
  763. X   AddHelpText(Cclist, "Cc", Cc_Help_Text);
  764. X  
  765. X!  n = 0;
  766. X!  XtSetArg(args[n], XtNfromVert, lab3);                    n++;
  767. X!  XtSetArg(args[n], XtNfromHoriz, NULL);                    n++;
  768. X!  XtSetArg(args[n], XtNwidth, scn / 2);                    n++;
  769. X!  XtSetArg(args[n], XtNheight, XMail.buttonHeight);            n++;
  770. X!  XtSetArg(args[n], XtNfont, TextFontStr);                n++;
  771. X!  lab2 = XtCreateManagedWidget("Autograph", commandWidgetClass, Layout, args, n);
  772. X  
  773. X!  XtAddCallback(lab2, XtNcallback, (XtCallbackProc) Autograph, (caddr_t) NULL);
  774. X  
  775. X   list = (menuList **) XtMalloc(4 * sizeof(menuList *));
  776. X  
  777. X   b1.label = "Add your autograph string Sign (~A)";
  778. X--- 86,190 ----
  779. X  sendMail(parent)
  780. X  Widget parent;
  781. X  {
  782. X!  Arg            args[10];
  783. X   Display        *ad;
  784. X   Widget            Popup, Layout;
  785. X!  Widget            lab1, lab2, lab3, lab4;
  786. X!  Widget            To, Subject, Cclist, Bcc, Last;
  787. X   Window            aw, dumy;
  788. X!  String            Editor, pgm;
  789. X   menuList_p        *list;
  790. X   menuList        b1, b2, b3;
  791. X!  char            *rindex(), cmd[BUFSIZ];
  792. X   int            x, y, scn;
  793. X  
  794. X  
  795. X!  aw  = XtWindow(WidgetOf(WidgetOf(toplevel, "topBox"), "statusWindow"));
  796. X!  ad  = XtDisplay(WidgetOf(WidgetOf(toplevel, "topBox"), "statusWindow"));
  797. X   scn = DefaultScreen(ad);
  798. X  
  799. X!  XTranslateCoordinates(ad,aw,RootWindow(ad,scn),XMail.menuX,0,&x,&y,&dumy);
  800. X  
  801. X   scn = XMail.shellWidth - 100;
  802. X  
  803. X!  XtSetArg(args[0], XtNinput, True);
  804. X!  XtSetArg(args[1], XtNwidth, scn);
  805. X!  XtSetArg(args[2], XtNheight, 20 + XMail.buttonHeight * 5);
  806. X!  XtSetArg(args[3], XtNborderWidth, 2);
  807. X!  XtSetArg(args[4], XtNx, x);
  808. X!  XtSetArg(args[5], XtNy, y);
  809. X!  Popup = XtCreatePopupShell("popup", transientShellWidgetClass,parent,args,6);
  810. X  
  811. X!  XtSetArg(args[0], XtNdefaultDistance, 2);
  812. X!  Layout = XtCreateManagedWidget("SubjCc", formWidgetClass, Popup, args, 1);
  813. X  
  814. X!  XtSetArg(args[0], XtNfromVert, NULL);
  815. X!  XtSetArg(args[1], XtNfromHoriz, NULL);
  816. X!  XtSetArg(args[2], XtNlabel, "To:      ");
  817. X!  XtSetArg(args[3], XtNborderWidth, 0);
  818. X!  XtSetArg(args[4], XtNfont, TextFontStr);
  819. X!  XtSetArg(args[5], XtNheight, XMail.buttonHeight);
  820. X!  XtSetArg(args[6], XtNjustify, XtJustifyLeft);
  821. X!  XtSetArg(args[7], XtNinternalHeight, 0);
  822. X!  XtSetArg(args[8], XtNinternalWidth, 1);
  823. X!  lab1 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, 9);
  824. X  
  825. X   To = CreateInputWindow(Layout, "To", Recipient, BUFSIZ);
  826. X  
  827. X+  XtSetArg(args[0], XtNfromVert, NULL);
  828. X+  XtSetArg(args[1], XtNfromHoriz, lab1);
  829. X+  XtSetValues(To, args, 2);
  830. X+ 
  831. X   AddHelpText(To, "To", To_Help_Text);
  832. X  
  833. X!  XtSetArg(args[0], XtNfromVert, lab1);
  834. X!  XtSetArg(args[1], XtNfromHoriz, NULL);
  835. X!  XtSetArg(args[2], XtNlabel, "Subject: ");
  836. X!  lab2 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, 9);
  837. X  
  838. X   Subject = CreateInputWindow(Layout, "Subject", SubjBuf, BUFSIZ);
  839. X  
  840. X+  XtSetArg(args[0], XtNfromVert, To);
  841. X+  XtSetArg(args[1], XtNfromHoriz, lab2);
  842. X+  XtSetValues(Subject, args, 2);
  843. X+ 
  844. X   AddHelpText(Subject, "Subject", Subject_Help_Text);
  845. X  
  846. X!  XtSetArg(args[0], XtNfromVert, lab2);
  847. X!  XtSetArg(args[1], XtNfromHoriz, NULL);
  848. X!  XtSetArg(args[2], XtNlabel, "Cc:      ");
  849. X!  lab3 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, 9);
  850. X  
  851. X   Cclist = CreateInputWindow(Layout, "Cc", CcBuf, BUFSIZ);
  852. X  
  853. X+  XtSetArg(args[0], XtNfromVert, Subject);
  854. X+  XtSetArg(args[1], XtNfromHoriz, lab3);
  855. X+  XtSetValues(Cclist, args, 2);
  856. X+ 
  857. X   AddHelpText(Cclist, "Cc", Cc_Help_Text);
  858. X  
  859. X!  XtSetArg(args[0], XtNfromVert, lab3);
  860. X!  XtSetArg(args[1], XtNfromHoriz, NULL);
  861. X!  XtSetArg(args[2], XtNlabel, "Bcc:     ");
  862. X!  lab4 = XtCreateManagedWidget("SubjCc", labelWidgetClass, Layout, args, 9);
  863. X  
  864. X!  Bcc = CreateInputWindow(Layout, "Bcc", BccBuf, BUFSIZ);
  865. X  
  866. X+  XtSetArg(args[0], XtNfromVert, Cclist);
  867. X+  XtSetArg(args[1], XtNfromHoriz, lab4);
  868. X+  XtSetValues(Bcc, args, 2);
  869. X+ 
  870. X+  AddHelpText(Bcc, "Bcc", Bcc_Help_Text);
  871. X+ 
  872. X+  XtSetArg(args[0], XtNfromVert, Bcc);
  873. X+  XtSetArg(args[1], XtNfromHoriz, NULL);
  874. X+  XtSetArg(args[2], XtNwidth, scn / 2);
  875. X+  XtSetArg(args[3], XtNheight, XMail.buttonHeight);
  876. X+  XtSetArg(args[4], XtNfont, TextFontStr);
  877. X+  lab2 = XtCreateManagedWidget("Autograph", commandWidgetClass, Layout, args, 5);
  878. X+ 
  879. X+  XtAddCallback(lab2, XtNcallback, (XtCallbackProc) Autograph, (caddr_t) "A");
  880. X+ 
  881. X   list = (menuList **) XtMalloc(4 * sizeof(menuList *));
  882. X  
  883. X   b1.label = "Add your autograph string Sign (~A)";
  884. X***************
  885. X*** 220,242 ****
  886. X   Normalize(To);
  887. X   Normalize(Subject);
  888. X   Normalize(Cclist);
  889. X  
  890. X   XtFree(list);
  891. X  
  892. X!  n = 1;
  893. X!  if ((Editor = GetMailEnv("EDITOR")) == NULL &&
  894. X!      (Editor = GetMailEnv("VISUAL")) == NULL) {
  895. X!       Editor = DEFAULT_EDITOR;
  896. X!     n = 0;
  897. X!    }
  898. X  
  899. X!  sprintf(cmd,
  900. X!  "xterm -display %s -T \"xmail message entry - using %s\" -n xmail_%s -e %s %s",
  901. X!                        ad->display_name, Editor, Editor, Editor, tmpName);
  902. X   system(cmd);
  903. X  
  904. X!  if (n)
  905. X!     XtFree(Editor);
  906. X  
  907. X   XtPopup(Popup, XtGrabNone);
  908. X  
  909. X--- 222,243 ----
  910. X   Normalize(To);
  911. X   Normalize(Subject);
  912. X   Normalize(Cclist);
  913. X+  Normalize(Bcc);
  914. X  
  915. X   XtFree(list);
  916. X  
  917. X!  if ((Editor = GetMailEnv("VISUAL")) == NULL)
  918. X!       Editor = XtNewString(DEFAULT_VISUAL);
  919. X  
  920. X!  if ((pgm = rindex(Editor, '/')) == NULL) pgm = Editor;
  921. X!  else ++pgm;
  922. X! 
  923. X!  sprintf(cmd, "xterm -display %s -name \"XMail\" -T \"xmail message entry\" \
  924. X!  -n xmail_%s -e %s %s", ad->display_name, pgm, Editor, tmpName);
  925. X!                        
  926. X   system(cmd);
  927. X  
  928. X!  XtFree(Editor);
  929. X  
  930. X   XtPopup(Popup, XtGrabNone);
  931. X  
  932. X*** ../v1.0/make.file    Sun May 27 22:22:46 1990
  933. X--- make.file    Sun May 27 22:23:35 1990
  934. X***************
  935. X*** 32,39 ****
  936. X  #
  937. X  # Add -lXext if compiling under X11 Release 4 or later
  938. X  #
  939. X! #  LIBRARIES = -lXaw -lXmu -lXt -lX11 -lm
  940. X!   LIBRARIES = -lXaw -lXmu -lXt -lXext -lX11 -lm
  941. X      PROGRAM = xmail
  942. X         SRCS = \
  943. X          Mailwatch.c \
  944. X--- 32,39 ----
  945. X  #
  946. X  # Add -lXext if compiling under X11 Release 4 or later
  947. X  #
  948. X! #  LIBRARIES = -lXaw -lXmu -lXt -lX11
  949. X!   LIBRARIES = -lXaw -lXmu -lXt -lXext -lX11
  950. X      PROGRAM = xmail
  951. X         SRCS = \
  952. X          Mailwatch.c \
  953. X*** ../v1.0/parser.c    Sun May 27 21:05:56 1990
  954. X--- parser.c    Sun May 27 21:11:37 1990
  955. X***************
  956. X*** 122,131 ****
  957. X   Cardinal    j, k, msgnum;
  958. X   XtTextBlock    textblock;
  959. X   XtTextPosition    pos;
  960. X!  Widget        button, popup;
  961. X   char        tmp[128], *c, *index();
  962. X   static    String    old_msg = NULL;
  963. X-  static int    shown_msg = 0;
  964. X  
  965. X  
  966. X   j = match(command_pattern, Command);
  967. X--- 122,132 ----
  968. X   Cardinal    j, k, msgnum;
  969. X   XtTextBlock    textblock;
  970. X   XtTextPosition    pos;
  971. X!  Widget        button, icon, popup, iw;
  972. X   char        tmp[128], *c, *index();
  973. X+  int        num;
  974. X+  static    Boolean    first_time = True;
  975. X   static    String    old_msg = NULL;
  976. X  
  977. X  
  978. X   j = match(command_pattern, Command);
  979. X***************
  980. X*** 134,187 ****
  981. X  ** If error on startup, mail has terminated connection.  Remove our input
  982. X  ** handler, close the file from our end, and indicate that no connection
  983. X  ** exists.  Otherwise, establish conversation requirements and display the
  984. X! ** current message.  Track current message shown for delete display control.
  985. X! ** If *Show_Last: resource is NOT False, show latest message, if none new.
  986. X  */
  987. X      case C_START :  if (O_BELL == match(output_pattern, msg)) {
  988. X                         XtRemoveInput(mailInputId);
  989. X-                        fclose(mailfp);
  990. X                         close(mail_fd);
  991. X                         mailpid = 0;
  992. X                 LASTCH(msg) = '\0';    /* Don't ring Bell() for this */
  993. X                 Bell(msg);
  994. X!                UpdateTitleBar("No current folder");
  995. X                         XtFree(msg);
  996. X                 *msg = '\0';
  997. X                        } else {
  998. X! #ifdef X11R3
  999. X!                        XtFree(QueryMail("set screen=100 nocrt noautoprint"));
  1000. X  #else
  1001. X!                        XtFree(QueryMail("set screen=500 nocrt noautoprint"));
  1002. X  #endif
  1003. X                         if (msgnum = file_handler(1)) {
  1004. X                            sprintf(tmp, "size %d", msgnum);
  1005. X                            XtFree(msg);
  1006. X                            msg = QueryMail(tmp);
  1007. X!                           c = index(msg, '/');
  1008. X!                           if (65536 < atoi(++c))
  1009. X                               strcpy(msg, " ");    /* Don't auto-read huge msgs */
  1010. X                            else {
  1011. X                               sprintf(tmp, "%d", msgnum);
  1012. X                               XtFree(msg);
  1013. X                               msg = QueryMail(tmp);
  1014. X!                              shown_msg = msgnum;
  1015. X                              }
  1016. X                           }
  1017. X                        }
  1018. X                  break;
  1019. X  /*
  1020. X  ** In response to normal or change folder commands, test output.  If an
  1021. X! ** error, display message in status window and ring bell.  If we have
  1022. X! ** text of next mail message, tell index_handler to mark its number, else
  1023. X! ** retrieve the appropriate message text (which also marks its number).
  1024. X! ** If *Show_Last: resource is NOT False, file cmd shows latest, if none new.
  1025. X! ** Track current message shown for delete display control.
  1026. X  */
  1027. X      case C_EXEC  :
  1028. X      case C_FILE  :  j = match(output_pattern, msg);
  1029. X              switch (j) {
  1030. X!                case O_BELL  : Bell(msg); XtFree(msg); *msg='\0'; break;
  1031. X!                case O_EXEC  : shown_msg = index_handler(0);  break;
  1032. X                 case O_FILE  : msgnum = file_handler(1);
  1033. X                                c = index(msg, '\n');
  1034. X                                if ((int)(c - msg) < strlen(msg) - 1) {
  1035. X--- 135,219 ----
  1036. X  ** If error on startup, mail has terminated connection.  Remove our input
  1037. X  ** handler, close the file from our end, and indicate that no connection
  1038. X  ** exists.  Otherwise, establish conversation requirements and display the
  1039. X! ** current message.  If *Show_Last: resource is NOT False, show latest, if
  1040. X! ** none are newer.  We delay setting the icon event handler until now, to
  1041. X! ** ensure mail startup completed before being interrupted by a map event,
  1042. X! ** for the case where we have been started iconic.
  1043. X  */
  1044. X      case C_START :  if (O_BELL == match(output_pattern, msg)) {
  1045. X                         XtRemoveInput(mailInputId);
  1046. X                         close(mail_fd);
  1047. X                         mailpid = 0;
  1048. X                 LASTCH(msg) = '\0';    /* Don't ring Bell() for this */
  1049. X                 Bell(msg);
  1050. X!                (void) UpdateTitleBar("No current folder");
  1051. X                         XtFree(msg);
  1052. X                 *msg = '\0';
  1053. X                        } else {
  1054. X! #if XtSpecificationRelease >= 4
  1055. X!                        strcpy(tmp, "set screen=500 ");
  1056. X  #else
  1057. X!                        strcpy(tmp, "set screen=100 ");
  1058. X  #endif
  1059. X+                        /* default action for xmail is hold (ala mailtool) */
  1060. X+                        if (c = GetMailrc("nohold")) XtFree(c);
  1061. X+                        else strcat(tmp, "hold ");
  1062. X+ 
  1063. X+                        strcat(tmp, "nocrt noreplyall");
  1064. X+ 
  1065. X+                        c = QueryMail(tmp);
  1066. X+                        XtFree(c);
  1067. X+ 
  1068. X                         if (msgnum = file_handler(1)) {
  1069. X                            sprintf(tmp, "size %d", msgnum);
  1070. X                            XtFree(msg);
  1071. X                            msg = QueryMail(tmp);
  1072. X!                           if (! (c = index(msg, '/')))    /* UCB #: lines/size */
  1073. X!                              c = index(msg, ' ');    /* Ultrix = #: size */
  1074. X!                           if (c && 65536 < atoi(++c))
  1075. X                               strcpy(msg, " ");    /* Don't auto-read huge msgs */
  1076. X                            else {
  1077. X                               sprintf(tmp, "%d", msgnum);
  1078. X                               XtFree(msg);
  1079. X                               msg = QueryMail(tmp);
  1080. X!                              markIndex(" ");
  1081. X                              }
  1082. X                           }
  1083. X                        }
  1084. X+                     if (first_time) {        /* only need to do this once */
  1085. X+                        icon = XtNameToWidget(toplevel, "icon");
  1086. X+                        XtAddEventHandler(icon, StructureNotifyMask, False,
  1087. X+                                          icon_handler, NULL);
  1088. X+                        first_time = False;
  1089. X+                       }
  1090. X                  break;
  1091. X  /*
  1092. X  ** In response to normal or change folder commands, test output.  If an
  1093. X! ** error, display message in status window and ring bell.  If current
  1094. X! ** folder is our bogus folder, erase any text and index and note state.
  1095. X! ** If we have text of next mail message, tell index_handler to mark its
  1096. X! ** number, else retrieve the appropriate message text (which also marks
  1097. X! ** its number).  If *Show_Last: resource is NOT False, file cmd shows
  1098. X! ** latest, if none new.
  1099. X  */
  1100. X      case C_EXEC  :
  1101. X      case C_FILE  :  j = match(output_pattern, msg);
  1102. X              switch (j) {
  1103. X!                case O_BELL  : Bell(msg);
  1104. X!                                       XtFree(msg);
  1105. X!                                       msg = QueryMail("file");
  1106. X!                                       if (strncmp(&msg[1], tmpName, strlen(tmpName)) == 0) {
  1107. X!                                  UpdateTitleBar("No current folder");
  1108. X!                                          iw = WidgetOf(toplevel, "topBox");
  1109. X!                                          writeText(WidgetOf(iw, "indexWindow"), " ", FALSE);
  1110. X!                                          writeTo(WidgetOf(iw, "textWindow"), " ");
  1111. X!                                         }
  1112. X!                                       XtFree(msg);
  1113. X!                                       *msg='\0';
  1114. X!                                       break;
  1115. X!                case O_EXEC  : msgnum = index_handler(0, 0);
  1116. X!                                       markIndex(" ");
  1117. X!                                       break;
  1118. X                 case O_FILE  : msgnum = file_handler(1);
  1119. X                                c = index(msg, '\n');
  1120. X                                if ((int)(c - msg) < strlen(msg) - 1) {
  1121. X***************
  1122. X*** 193,206 ****
  1123. X                                        if (msgnum) {
  1124. X                                           sprintf(tmp, "size %d", msgnum);
  1125. X                                           msg = QueryMail(tmp);
  1126. X!                                          c = index(msg, '/');
  1127. X!                                          if (65536 < atoi(++c))
  1128. X                              strcpy(msg, " ");
  1129. X                                           else {
  1130. X                                              sprintf(tmp, "%d", msgnum);
  1131. X                                              XtFree(msg);
  1132. X                                              msg = QueryMail(tmp);
  1133. X!                                             shown_msg = msgnum;
  1134. X                                             }
  1135. X                                          }
  1136. X                                break;
  1137. X--- 225,239 ----
  1138. X                                        if (msgnum) {
  1139. X                                           sprintf(tmp, "size %d", msgnum);
  1140. X                                           msg = QueryMail(tmp);
  1141. X!                                          if (! (c = index(msg, '/')))
  1142. X!                                             c = index(msg, ' ');
  1143. X!                                          if (c && 65536 < atoi(++c))
  1144. X                              strcpy(msg, " ");
  1145. X                                           else {
  1146. X                                              sprintf(tmp, "%d", msgnum);
  1147. X                                              XtFree(msg);
  1148. X                                              msg = QueryMail(tmp);
  1149. X!                                             markIndex(" ");
  1150. X                                             }
  1151. X                                          }
  1152. X                                break;
  1153. X***************
  1154. X*** 207,216 ****
  1155. X                    }
  1156. X                      break;
  1157. X  /*
  1158. X! ** When deleting a message, if the message deleted was not the one currently
  1159. X! ** shown, simply mark that message's index line with a capital 'D'.  Else, if
  1160. X! ** we deleted the currently displayed message, or we undeleted one, display
  1161. X! ** the next (or undeleted) message, and track our message shown number.
  1162. X  */
  1163. X      case C_DELETE : if (O_BELL == match(output_pattern, msg)) {
  1164. X                         Bell(msg);
  1165. X--- 240,248 ----
  1166. X                    }
  1167. X                      break;
  1168. X  /*
  1169. X! ** When deleting a message, simply mark that index line with a capital 'D'.
  1170. X! ** If un-deleting, mark that index line with a blank ' '.  If no current
  1171. X! ** index, restore it.
  1172. X  */
  1173. X      case C_DELETE : if (O_BELL == match(output_pattern, msg)) {
  1174. X                         Bell(msg);
  1175. X***************
  1176. X*** 218,267 ****
  1177. X                         *msg = '\0';
  1178. X                        } else {
  1179. X                         pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel,
  1180. X!                                                   "vpane"), "indexWindow")) + 1;
  1181. X                         msgnum = PositionToMsgNumber(pos);
  1182. X!                        if (*Command == 'd' && msgnum && msgnum != shown_msg) {
  1183. X!                           XtTextSetInsertionPoint(WidgetOf(WidgetOf(toplevel,
  1184. X!                                                  "vpane"), "indexWindow"), pos);
  1185. X!                           textblock.firstPos    = 0;
  1186. X!                           textblock.length    = 1;
  1187. X!                           textblock.ptr        = "D";
  1188. X!                           textblock.format    = FMT8BIT;
  1189. X!                           XtTextReplace(WidgetOf(WidgetOf(toplevel, "vpane"),
  1190. X!                                         "indexWindow"), pos, pos+1, &textblock);
  1191. X!                   index_handler(++msgnum); /* point to next msg */
  1192. X!                           XtFree(msg);
  1193. X!                           *msg = '\0';
  1194. X!                          } else {
  1195. X!                           if (msgnum = file_handler(0)) {
  1196. X!                              sprintf(tmp, "size %d", msgnum);
  1197. X!                              XtFree(msg);
  1198. X!                              msg = QueryMail(tmp);
  1199. X!                              c = index(msg, '/');
  1200. X!                              if (65536 < atoi(++c))
  1201. X!                                 strcpy(msg, " ");
  1202. X!                              else {
  1203. X!                              sprintf(tmp, "%d", msgnum);
  1204. X!                              XtFree(msg);
  1205. X!                              msg = QueryMail(tmp);
  1206. X!                              shown_msg = msgnum;
  1207. X                              }
  1208. X                           }
  1209. X                        }
  1210. X-                       }
  1211. X              break;
  1212. X  /*
  1213. X  ** In response to a request to view new mail, first reset the mailbox flag.
  1214. X  ** If mail came back with an error, complain to the user.  Otherwise, clear
  1215. X  ** the Newmail command button highlighting, and (if it exists) destroy the
  1216. X! ** current folder popup list.  Then display new mail text and track number.
  1217. X  */
  1218. X      case C_NEWMAIL:
  1219. X!                     reset_mailbox(WidgetOf(WidgetOf(toplevel,"icon"),"mailbox"));
  1220. X!             UnsetNewmail(WidgetOf(WidgetOf(toplevel, "vpane"),
  1221. X!                                                    "commandPanel"), NULL, NULL);
  1222. X!             button = WidgetOf(WidgetOf(WidgetOf(toplevel, "vpane"),
  1223. X                                                       "commandPanel"), "Folder");
  1224. X              if (popup = WidgetOf(button, "popupList"))
  1225. X                 XtDestroyWidget(popup);
  1226. X                      if (O_BELL == match(output_pattern, msg)) {
  1227. X--- 250,293 ----
  1228. X                         *msg = '\0';
  1229. X                        } else {
  1230. X                         pos = XtTextGetInsertionPoint(WidgetOf(WidgetOf(toplevel,
  1231. X!                                                  "topBox"), "indexWindow")) + 1;
  1232. X                         msgnum = PositionToMsgNumber(pos);
  1233. X!                        if (*Command == 'd' && msgnum) {
  1234. X!                           markIndex("D");
  1235. X!                   num = msgnum;
  1236. X!                   msgnum = index_handler(++msgnum, 0); /* next msg */
  1237. X!                           if (msgnum != num) markIndex(" ");
  1238. X!                          }
  1239. X!                        if (*Command == 'u') {
  1240. X!                   c = QueryMail("=");
  1241. X!                   sscanf(c, "%d", &msgnum);
  1242. X!                   XtFree(c);
  1243. X!                           iw = WidgetOf(WidgetOf(toplevel, "topBox"),"indexWindow");
  1244. X!                           if (TextGetLastPos(iw) < (XtTextPosition) 4) {
  1245. X!                              c = QueryMail("h");
  1246. X!                              writeText(iw, c, FALSE);
  1247. X!                      XtFree(c);
  1248. X                              }
  1249. X+                   msgnum = index_handler(msgnum, 1);
  1250. X+                           markIndex(" ");
  1251. X                           }
  1252. X+                        c = QueryMail("file");    /* resets current msg to 1 */
  1253. X+                        (void) UpdateTitleBar(c);
  1254. X+                        sprintf(tmp, "f %d", msgnum);
  1255. X+                c = QueryMail(tmp);    /* reset real current msg */
  1256. X+                        XtFree(c);
  1257. X                        }
  1258. X              break;
  1259. X  /*
  1260. X  ** In response to a request to view new mail, first reset the mailbox flag.
  1261. X  ** If mail came back with an error, complain to the user.  Otherwise, clear
  1262. X  ** the Newmail command button highlighting, and (if it exists) destroy the
  1263. X! ** current folder popup list.  Then display any new mail text.
  1264. X  */
  1265. X      case C_NEWMAIL:
  1266. X!             button = WidgetOf(WidgetOf(WidgetOf(toplevel, "topBox"),
  1267. X                                                       "commandPanel"), "Folder");
  1268. X+             UnsetNewmail(button, NULL, NULL);
  1269. X              if (popup = WidgetOf(button, "popupList"))
  1270. X                 XtDestroyWidget(popup);
  1271. X                      if (O_BELL == match(output_pattern, msg)) {
  1272. X***************
  1273. X*** 282,295 ****
  1274. X                         if (msgnum) {
  1275. X                            sprintf(tmp, "size %d", msgnum);
  1276. X                            msg = QueryMail(tmp);
  1277. X!                           c = index(msg, '/');
  1278. X!                           if (65536 < atoi(++c))
  1279. X                       strcpy(msg, " ");
  1280. X                            else {
  1281. X                               sprintf(tmp, "%d", msgnum);
  1282. X                               XtFree(msg);
  1283. X                               msg = QueryMail(tmp);
  1284. X!                              shown_msg = msgnum;
  1285. X                              }
  1286. X                           }
  1287. X                        }
  1288. X--- 308,322 ----
  1289. X                         if (msgnum) {
  1290. X                            sprintf(tmp, "size %d", msgnum);
  1291. X                            msg = QueryMail(tmp);
  1292. X!                           if (! (c = index(msg, '/')))
  1293. X!                              c = index(msg, ' ');
  1294. X!                           if (c && 65536 < atoi(++c))
  1295. X                       strcpy(msg, " ");
  1296. X                            else {
  1297. X                               sprintf(tmp, "%d", msgnum);
  1298. X                               XtFree(msg);
  1299. X                               msg = QueryMail(tmp);
  1300. X!                              markIndex(" ");    /* 'cause we just read it */
  1301. X                              }
  1302. X                           }
  1303. X                        }
  1304. X***************
  1305. X*** 307,313 ****
  1306. X  */
  1307. X                 case O_PRINT:
  1308. X                              sscanf(&Command[2], "%d", &j);
  1309. X!                             sscanf(&msg[26], "%*d/%d", &k);
  1310. X                              sprintf(tmp,
  1311. X                               "Message %d sent to printer -- %d bytes\n", j, k);
  1312. X                              Bell(tmp);
  1313. X--- 334,341 ----
  1314. X  */
  1315. X                 case O_PRINT:
  1316. X                              sscanf(&Command[2], "%d", &j);
  1317. X!                             c = rindex(msg, '/');
  1318. X!                             sscanf(c, "/%d", &k);
  1319. X                              sprintf(tmp,
  1320. X                               "Message %d sent to printer -- %d bytes\n", j, k);
  1321. X                              Bell(tmp);
  1322. X***************
  1323. X*** 327,338 ****
  1324. X      for (j = strlen(msg)-1; j > 1 && msg[j] == '\n' && msg[j-1] == '\n'; j--);
  1325. X      msg[++j] = '\0';            /* drop all but the last newline */
  1326. X  
  1327. X!     writeTo(WidgetOf(WidgetOf(toplevel, "vpane"), "textWindow"), msg);
  1328. X     }
  1329. X  } /* parse */
  1330. X  
  1331. X! #undef    BUFSIZ
  1332. X! #define    BUFSIZ    8192
  1333. X  
  1334. X  /*
  1335. X  ** @(#)QueryMail() - Sends a command and returns corresponding output.
  1336. X--- 355,365 ----
  1337. X      for (j = strlen(msg)-1; j > 1 && msg[j] == '\n' && msg[j-1] == '\n'; j--);
  1338. X      msg[++j] = '\0';            /* drop all but the last newline */
  1339. X  
  1340. X!     writeTo(WidgetOf(WidgetOf(toplevel, "topBox"), "textWindow"), msg);
  1341. X     }
  1342. X  } /* parse */
  1343. X  
  1344. X! #define    FILEBUF    8192
  1345. X  
  1346. X  /*
  1347. X  ** @(#)QueryMail() - Sends a command and returns corresponding output.
  1348. X***************
  1349. X*** 344,350 ****
  1350. X  {
  1351. X   Widget        w, x, y, z;
  1352. X   int        j, outputsize, size, length = strlen(MailPrompt);
  1353. X!  char *output = "", s[BUFSIZ];
  1354. X  
  1355. X  
  1356. X   if (! mailpid)
  1357. X--- 371,377 ----
  1358. X  {
  1359. X   Widget        w, x, y, z;
  1360. X   int        j, outputsize, size, length = strlen(MailPrompt);
  1361. X!  char *output = "", s[FILEBUF];
  1362. X  
  1363. X  
  1364. X   if (! mailpid)
  1365. X***************
  1366. X*** 358,364 ****
  1367. X         writeMail(s);
  1368. X        }
  1369. X  
  1370. X!     w = WidgetOf(toplevel, "vpane");
  1371. X      x = WidgetOf(w, "indexWindow");
  1372. X      y = WidgetOf(w, "textWindow");
  1373. X      z = WidgetOf(WidgetOf(w, "commandPanel"), "fileWindow");
  1374. X--- 385,391 ----
  1375. X         writeMail(s);
  1376. X        }
  1377. X  
  1378. X!     w = WidgetOf(toplevel, "topBox");
  1379. X      x = WidgetOf(w, "indexWindow");
  1380. X      y = WidgetOf(w, "textWindow");
  1381. X      z = WidgetOf(WidgetOf(w, "commandPanel"), "fileWindow");
  1382. X***************
  1383. X*** 370,389 ****
  1384. X  /*
  1385. X  ** allocate one block to 'output' to begin with
  1386. X  */
  1387. X!     outputsize = BUFSIZ;
  1388. X      output = XtMalloc(outputsize);
  1389. X      strcpy(output, "");
  1390. X  
  1391. X      for (;;) {
  1392. X!     while ((size = read(mail_fd, s, BUFSIZ)) == -1);
  1393. X  
  1394. X!         if (size == 0) break;        /* END-OF-FILE? should never happen */
  1395. X! 
  1396. X!         if (size < BUFSIZ)
  1397. X             s[size] = '\0';
  1398. X  
  1399. X          if (strlen(output) + size > outputsize) {
  1400. X!            outputsize += BUFSIZ;
  1401. X             output = XtRealloc(output, outputsize);
  1402. X            }
  1403. X          strcat(output, s);
  1404. X--- 397,415 ----
  1405. X  /*
  1406. X  ** allocate one block to 'output' to begin with
  1407. X  */
  1408. X!     outputsize = FILEBUF;
  1409. X      output = XtMalloc(outputsize);
  1410. X      strcpy(output, "");
  1411. X  
  1412. X      for (;;) {
  1413. X!         if ((size = read(mail_fd, s, FILEBUF)) == 0)
  1414. X!            break;            /* END-OF-FILE? should never happen */
  1415. X  
  1416. X!         if (size < FILEBUF)
  1417. X             s[size] = '\0';
  1418. X  
  1419. X          if (strlen(output) + size > outputsize) {
  1420. X!            outputsize += FILEBUF;
  1421. X             output = XtRealloc(output, outputsize);
  1422. X            }
  1423. X          strcat(output, s);
  1424. X*** ../v1.0/regex.c    Sun May 27 21:06:01 1990
  1425. X--- regex.c    Sun May 27 21:10:02 1990
  1426. X***************
  1427. X*** 112,117 ****
  1428. X--- 112,119 ----
  1429. X  #include <alloca.h>
  1430. X  #endif
  1431. X  
  1432. X+ static int bcmp_translate();
  1433. X+ 
  1434. X  #ifdef emacs
  1435. X  
  1436. X  /* The `emacs' switch turns on certain special matching commands
  1437. X*** ../v1.0/utils.c    Sun May 27 21:05:57 1990
  1438. X--- utils.c    Sun May 27 21:11:37 1990
  1439. X***************
  1440. X*** 38,45 ****
  1441. X   * The following software modules were created and are Copyrighted by National
  1442. X   * Semiconductor Corporation:
  1443. X   *
  1444. X!  * 1. Normalize: and
  1445. X!  * 2. PositionToMsgNumber.
  1446. X   *
  1447. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1448. X   *
  1449. X--- 38,46 ----
  1450. X   * The following software modules were created and are Copyrighted by National
  1451. X   * Semiconductor Corporation:
  1452. X   *
  1453. X!  * 1. Normalize:
  1454. X!  * 2. MarkIndex: and
  1455. X!  * 3. PositionToMsgNumber.
  1456. X   *
  1457. X   * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  1458. X   *
  1459. X***************
  1460. X*** 48,53 ****
  1461. X--- 49,55 ----
  1462. X  
  1463. X  #include <ctype.h>
  1464. X  #include "global.h"
  1465. X+ #include "patchlevel.h"
  1466. X  
  1467. X  
  1468. X  /*
  1469. X***************
  1470. X*** 63,68 ****
  1471. X--- 65,99 ----
  1472. X  
  1473. X  
  1474. X  /*
  1475. X+ ** @(#)markIndex() - add or remove tag from head of index line
  1476. X+ */
  1477. X+ void
  1478. X+ markIndex(s)
  1479. X+ char    *s;
  1480. X+ {
  1481. END_OF_FILE
  1482. if test 51482 -ne `wc -c <'Patch.01c'`; then
  1483.     echo shar: \"'Patch.01c'\" unpacked with wrong size!
  1484. fi
  1485. # end of 'Patch.01c'
  1486. fi
  1487. echo shar: End of archive 3 \(of 5\).
  1488. cp /dev/null ark3isdone
  1489. MISSING=""
  1490. for I in 1 2 3 4 5 ; do
  1491.     if test ! -f ark${I}isdone ; then
  1492.     MISSING="${MISSING} ${I}"
  1493.     fi
  1494. done
  1495. if test "${MISSING}" = "" ; then
  1496.     echo You have unpacked all 5 archives.
  1497.     rm -f ark[1-9]isdone
  1498. else
  1499.     echo You still need to unpack the following archives:
  1500.     echo "        " ${MISSING}
  1501. fi
  1502. ##  End of shell archive.
  1503. exit 0
  1504.  
  1505. dan
  1506. ----------------------------------------------------
  1507. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1508. Opinions expressed reflect those of the author only.
  1509.